package draw;

import java.awt.image.BufferedImage;
import java.awt.image.Raster;

/**
 * array[width][height] 
 * j height array[0].length
 * i width array.length
 * rast.getPixel(i, j, pixel);
 */

public class ArrayFromImage {

    private BufferedImage src = null;
    private int[][] imageDescription; 
    
    public ArrayFromImage(BufferedImage src) {
        this.src = src;
        doArray();
    }

    private void doArray() {
        int width = src.getWidth();
        int height = src.getHeight();

        imageDescription = new int[width][height];

        Raster rast = src.getRaster();
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {

                int pixel[] = new int[4];
                int pixelPos = 1;
                rast.getPixel(i, j, pixel);
                int pixelVal = pixel[pixelPos];
                imageDescription[i][j] = pixelVal;
            }
        }
    }

    public int[][] getImageDescription() {
        return imageDescription;
    }
    
}
